$filename = "/unexistant_file"
begin
   file = File.open($filename)
   if file
      puts "File opened successfully"
   end
rescue
      file = STDIN
      $filename = "/test"
      retry
end
print file, "==", STDIN, "\n"